
{% extends 'base.html' %}

{% block css%}
<style type="text/css">

.display_resp {
	background: #FFFFCC;
}

</style>
{% endblock %}

{% block body%} 
<div class="row">

	<div class="col-md-9">
        <h4>Export Parameters</h4>
        <table class="table table-hover table-condensed form-inline">

        	<tr>
              <td>

						<label class="checkbox-inline">
							<input class="my_checkbox" type="checkbox" id="ANALOG" value="ANALOG">
							&nbsp;&nbsp;&nbsp;&nbsp;ANALOG
						</label>

						<label class="checkbox-inline">
							<input class="my_checkbox" type="checkbox" id="MSA" value="MSA">
							&nbsp;&nbsp;&nbsp;&nbsp;MSA
						</label>

            <label class="checkbox-inline">
					  <input class="my_checkbox" type="checkbox" id="PIN" value="PIN">
					  &nbsp;&nbsp;&nbsp;&nbsp;PIN
					</label>

					&nbsp;&nbsp;&nbsp;&nbsp;
					<label class="checkbox-inline">
					  <input class="my_checkbox"  type="checkbox" id="ADC" value="ADC">
					  &nbsp;&nbsp;&nbsp;&nbsp;ADC
					</label>

					&nbsp;&nbsp;&nbsp;&nbsp;
					<label class="checkbox-inline">
					  <input class="my_checkbox"  type="checkbox" id="DAC" value="DAC">
					  &nbsp;&nbsp;&nbsp;&nbsp;DAC
					</label>

					&nbsp;&nbsp;&nbsp;&nbsp;
					<label class="checkbox-inline">
					  <input class="my_checkbox"  type="checkbox" id="DDM" value="DDM">
					  &nbsp;&nbsp;&nbsp;&nbsp;DDM
					</label>

					&nbsp;&nbsp;&nbsp;&nbsp;
					<label class="checkbox-inline">
					  <input class="my_checkbox"  type="checkbox" id="MODULE_INFO" value="MODULE_INFO">
					  &nbsp;&nbsp;&nbsp;&nbsp;MODULE INFO
					</label>

					&nbsp;&nbsp;&nbsp;&nbsp;
					<label class="checkbox-inline">
					  <input class="my_checkbox"  type="checkbox" id="PAGES_DATA" value="PAGES_DATA">
					  &nbsp;&nbsp;&nbsp;&nbsp;PAGES DATA
					</label>					
                </td>
            </tr><span>
            	

            </span>
            <tr>
              <td>
                    <span id="parameters" style="color: blue;">
                    </span>
                </td>
            </tr>
            <tr>
                <td>
                    <button class="btn btn-lg btn-success pull-right" id="btn_export_parameters">
                        Export Data
                        &nbsp;&nbsp;
                        <i id="btn_export_parameters_loading" class="fa fa-refresh fa-spin fa-fw"></i>
                    </button>
                </td>
            </tr>

        </table>

	</div>

	<div class="col-md-3">
	</div>

</div>
{% endblock %}

{% block js%} 
{{ super() }}
<script type="text/javascript">

	$(document).ready(function(){
	    $("#btn_export_parameters_loading").hide();
	    // $("#parameters").hide();

	    $("#btn_export_parameters").click(function() {

	    		if($("#ANALOG").prop("checked") == true) ckb_ANALOG = 'ANALOG'; else ckb_ANALOG = '-';
	    		if($("#MSA").prop("checked") == true) ckb_MSA = 'MSA'; else ckb_MSA = '-';
	        if($("#PIN").prop("checked") == true) ckb_PIN = 'PIN'; else ckb_PIN = '-';
	        if($("#ADC").prop("checked") == true) ckb_ADC = 'ADC'; else ckb_ADC = '-';
	        if($("#DAC").prop("checked") == true) ckb_DAC = 'DAC'; else ckb_DAC = '-';
	        if($("#DDM").prop("checked") == true) ckb_DDM = 'DDM'; else ckb_DDM = '-';
	        if($("#MODULE_INFO").prop("checked") == true) ckb_MODULE_INFO = 'MODULE_INFO'; else ckb_MODULE_INFO = '-';
	        if($("#PAGES_DATA").prop("checked") == true) ckb_PAGES_DATA = 'PAGES_DATA'; else ckb_PAGES_DATA = '-';

	        if(ckb_ANALOG == '-' && ckb_MSA == '-' && ckb_PIN == '-' && ckb_ADC == '-' && ckb_DAC == '-' && ckb_DDM == '-' && ckb_MODULE_INFO == '-' && ckb_PAGES_DATA == '-')
	        {
	        	alert('Select at least one export item!');
	        	return false;
	        }

	        $("#btn_export_parameters_loading").show();
	        $("#parameters").html('Data exporting, please wait ...');
	        $.post(
	            "api/btn_export_parameters", {
	            	'ckb_ANALOG' : ckb_ANALOG,
	            	'ckb_MSA' : ckb_MSA,
	            	'ckb_PIN' : ckb_PIN,
	            	'ckb_ADC' : ckb_ADC,
	            	'ckb_DAC' : ckb_DAC,
	            	'ckb_DDM' : ckb_DDM,
	            	'ckb_MODULE_INFO' : ckb_MODULE_INFO,
	            	'ckb_PAGES_DATA' : ckb_PAGES_DATA
	            },
	            function(data, status) {
	                // console.log("data: " + data);
	                // alert(data);
	                $("#btn_export_parameters_loading").hide();
	                $("#parameters").show();
	                $("#parameters").html("<a href='./static/files/" + data + "'>Get parameters file. &nbsp;&nbsp;<i class='glyphicon glyphicon-save'></i> </a>");

	                // alert('export all ...');
	            }
	        );
	    });
    
	});
</script>
{% endblock %}